package org.example.examfx02.tool;

import org.example.examfx02.entity.Course;
import org.example.examfx02.entity.SelectCourse;
import org.example.examfx02.entity.Student;
import org.example.examfx02.entity.Teacher;

import java.util.List;

public class WriteFile {

    private static final String STU_FILE = "src/main/resources/data/Student.json";
    private static final String TEA_FILE = "src/main/resources/data/Teacher.json";
    private static final String COURSE_FILE = "src/main/resources/data/Course.json";
    private static final String SC_FILE = "src/main/resources/data/SelectCourse.json";

    public static void writeStuFile(List<Student> students){
        // 保存为JSON文件
        boolean success = JsonFileUtil.saveListToJson(students,STU_FILE);
        if (success) {
            System.out.println("数据已成功保存为JSON文件");
        } else {
            System.out.println("保存失败");
        }
    }
    public static void writeTeaFile(List<Teacher> teachers){
        // 保存为JSON文件
        boolean success = JsonFileUtil.saveListToJson(teachers,TEA_FILE);
        if (success) {
            System.out.println("数据已成功保存为JSON文件");
        } else {
            System.out.println("保存失败");
        }
    }
    public static void writeCourseFile(List<Course> courses){
        // 保存为JSON文件
        boolean success = JsonFileUtil.saveListToJson(courses,COURSE_FILE);
        if (success) {
            System.out.println("数据已成功保存为JSON文件");
        } else {
            System.out.println("保存失败");
        }
    }
    public static void writeSelectCourseFile(List<SelectCourse> selectCourses){
        // 保存为JSON文件
        boolean success = JsonFileUtil.saveListToJson(selectCourses,SC_FILE);
        if (success) {
            System.out.println("数据已成功保存为JSON文件");
        } else {
            System.out.println("保存失败");
        }
    }
}
